import { FormSchema } from '/@/components/Table';
import { getDictTypeListApi } from '/@/api/admin/dict';
import { DICT } from '/@/enums/dict';

import modelerStore from '/@/store/modules/bpmnModeler';
const modeler = modelerStore();
const limitationList = [
  {
    label: '没有限制',
    value: 0,
  },
  {
    label: '处理人员达到一定程度时其他人不能再处理',
    value: 1,
  },
];
const limitCompareList = [
  {
    label: '按人数 (>=人)',
    value: 0,
  },
  {
    label: '按百分比 (>=%)',
    value: 1,
  },
];
export const basicSchemas: FormSchema[] = [
  {
    field: 'remindAddFlag',
    label: '消息通知方式',
    colProps: {
      span: 24,
    },
    component: 'ApiSelect',
    componentProps: {
      mode: 'multiple',
      api: getDictTypeListApi,
      labelField: 'label',
      valueField: 'intValue',
      placeholder: '请选择消息通知方式',
      params: {
        type: DICT.MSG_RUN_TYPE,
      },
      onChange: (e) => {
        setTimeout(() => {
          modeler.setActivitiesItem(modeler.getActiveId, 'remindAddFlag', e);
        });
      },
      getPopupContainer: () => document.body,
    },
  },
  {
    field: 'transLimit',
    label: '多状态处理限制',
    required: false,
    component: 'RadioGroup',

    colProps: {
      span: 24,
    },
    componentProps: {
      options: limitationList,
      onChange: (e) => {
        // console.log('hahahah--------', e);

        setTimeout(() => {
          if (e || e === 0) {
            modeler.setActivitiesItem(modeler.getActiveId, 'transLimit', e?.target?.value ?? e);
          }
        });
      },
    },
  },
  {
    field: 'compareCont',
    label: '多状态处理限制比较内容',
    component: 'InputNumber',
    colProps: {
      span: 24,
    },
    componentProps: {
      onBlur: (e) => {
        setTimeout(() => {
          modeler.setActivitiesItem(modeler.getActiveId, 'compareCont', e.target._value);
        });
      },
    },
  },
  {
    field: 'limitCompare',
    label: '多状态处理限制比较类型',
    component: 'Select',
    colProps: {
      span: 24,
    },
    componentProps: {
      options: limitCompareList,
      onChange: (e) => {
        setTimeout(() => {
          modeler.setActivitiesItem(modeler.getActiveId, 'limitCompare', e);
        });
      },
    },
  },
  {
    field: 'transLimitChoice',
    label: '多状态处理限制选项',
    component: 'Select',
    colProps: {
      span: 24,
    },
    componentProps: {
      onChange: (e) => {
        setTimeout(() => {
          modeler.setActivitiesItem(modeler.getActiveId, 'transLimitChoice', e);
        });
      },
    },
  },
];
